# -*- coding: utf-8 -*-
'''
@author: Hugo
@file: demo.py
@time: 2021/8/21 9:42
'''
###  此程序出错,有问题
# 数据地址   https://kuwo.cn/api/www/search/searchMusicBykeyWord?key=%E8%8F%B2%E8%8F%B2&pn=1&rn=30&httpsStatus=1&reqId=f31220a1-0230-11ec-990d-c186eca62f87

# 歌曲地址: https://gu-sycdn.kuwo.cn/260af061950fef583a1fac2961ac44b3/61206ad9/resource/n3/68/58/678270135.mp3
import requests

from utils import base
class Crawl(base.Spider):
    def crawl(self):
        headers = {
            'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64)',
               'csrf':'9RU7EE2D56A',
               'Referer':'http://www.kuwo.cn/search/list?' + '%E8%BD%BB%E9%9F%B3%E4%B9%90',
               'Cookie':'Hm_lvt_cdb524f42f0ce19b169a8071123a4797=1629510199; _ga=GA1.2.2085152892.1629510199; _gid=GA1.2.1035340629.1629510199; Hm_lpvt_cdb524f42f0ce19b169a8071123a4797=1629516953; kw_token=9RU7EE2D56A; _gat=1'
        }

        #  https://kuwo.cn/api/www/search/searchMusicBykeyWord?key=%E8%BD%BB%E9%9F%B3%E4%B9%90&pn=1&rn=30&httpsStatus=1&reqId=d33ed550-0237-11ec-990d-c186eca62f87
        url = 'http://www.kuwo.cn/api/www/search/searchMusicBykeyWord?' + '%E8%BD%BB%E9%9F%B3%E4%B9%90' + '&pn=1&rn=30&httpsStatus=1&reqId=d33ed550-0237-11ec-990d-c186eca62f87'
        res = requests.get(url = url,headers = headers)
        print(res.text)
s = Crawl()
s.crawl()



